package com.luo.wheresmytakeaway.controller;


import com.luo.wheresmytakeaway.pojo.Results;
import com.luo.wheresmytakeaway.pojo.User;
import com.luo.wheresmytakeaway.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;



@Slf4j
@RestController
public class loginController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Results login(@RequestBody User users) {
        log.info("login账户{}", users);
        String user = userService.login(users);
        if (user != null){
            return Results.success(user);
        }else{
            return Results.error("用户名或密码错误");
        }
    }

}
